package com.superman.supermarket.client.composite.preorder.sku;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.superman.mvpframe.client.widget.lazy.LazyImage;
import com.superman.supermarket.client.composite.IUIModule;

/**
 * 提交订单商品信息模块
 * 
 * @author superman
 * @version 2018年8月6日下午10:41:53
 */
public class PreorderSkuModule extends Composite implements IUIModule {

	interface PreorderSkuModuleUiBinder extends UiBinder<Widget, PreorderSkuModule> {
	}

	private static PreorderSkuModuleUiBinder uiBinder = GWT.create(PreorderSkuModuleUiBinder.class);

	protected String skuId;
	@UiField
	protected LazyImage skuimg;
	@UiField
	protected HTML skunamehtml, skupropnameshtml, salepricehtml, numhtml;

	protected @UiField FlowPanel skupanel, optpanel;
	protected int stype, num;

	/**
	 * 构造方法
	 * 
	 * @author superman
	 * @version 2018年8月6日 下午10:41:50
	 */
	public PreorderSkuModule() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public Map<String, Object> getData() {
		Map<String, Object> skuMap = new HashMap<String, Object>();
		skuMap.put("SKU_ID", this.skuId);
		skuMap.put("SKU_NUM", this.num);
		skuMap.put("STYPE", this.stype);
		return skuMap;
	}

	@Override
	public void setData(Map<String, Object> map) {

		this.skuId = String.valueOf(map.get("SKU_ID"));
		this.stype = (int) Double.parseDouble(String.valueOf(map.get("STYPE")));
		this.num = (int) Double.parseDouble(String.valueOf(map.get("SKU_NUM")));

		skuimg.setUrl(String.valueOf(map.get("PIC")));
		skunamehtml.setText(String.valueOf(map.get("NAME")));
		skupropnameshtml.setText(String.valueOf(map.get("PROPS_NAME")));

		double buyPrice = Double.parseDouble(String.valueOf(map.get("BUY_PRICE")));

		salepricehtml.setHTML("¥&nbsp;" + buyPrice);
		numhtml.setHTML("x&nbsp;" + num);

	}

}
